<template>
  <div class="bid-info">
    <h3>
      比价结束
    </h3>
    <div class="info-div">
      <div class="cleardix panel_end">
        <p class="fl">效率统计：</p>
        <time-line :showInfo="showInfo" :url="infourl" :formData="formData" ref="tim"></time-line>
        <el-button v-if="isShow" class="fr fr_right" icon="el-icon-success" type="success" @click="againInquiry">再次询价</el-button>
        <el-button class="fr fr_right" icon="el-icon-view" type="primary" @click.stop="() => {$refs.tim.toggleDiolag()}">查看日志</el-button>
      </div>
      <el-form :model="form">      
        <el-row class="el_row_bottom">
          <el-col :span="3" class="col_label">RFQ出发时间</el-col>
          <el-col :span="3" class="col_view">{{form.publishTime}}</el-col>
          <el-col :span="3" class="col_label">竞标供应商审核通过时间</el-col>
          <el-col :span="3" class="col_view">{{form.checkTime}}</el-col>
          <el-col :span="3" class="col_label">报价截止时间</el-col>
          <el-col :span="3" class="col_view">{{form.quoLimitTime}}</el-col>
          <el-col :span="3" class="col_label">提交比价时间</el-col>
          <el-col :span="3" class="col_view">{{form.submitCompTime}}</el-col>
        </el-row>
        <el-row class="el_row_bottom">
          <el-col :span="3" class="col_label">中标推荐时间</el-col>
          <el-col :span="3" class="col_view">{{form.submitWinTime}}</el-col>
          <el-col :span="3" class="col_label">价格审批通过时间</el-col>
          <el-col :span="15" class="col_view">{{form.checkWinTime}}</el-col>
        </el-row>             
      <div class="cleardix panel_end">
        <p>竞标标的：</p>
      </div>

        <el-row class="el_row_bottom">
          <el-col :span="3" class="col_label">小计</el-col>
          <el-col :span="3" class="col_view">{{form.rfqMaterialAllNum}}</el-col>
          <el-col :span="3" class="col_label">报价完成率</el-col>
          <el-col :span="3" class="col_view">{{form.rfqQuoteProportion}}</el-col>
          <el-col :span="3" class="col_label">作废数量</el-col>
          <el-col :span="3" class="col_view">{{form.materialCancelNum}}</el-col>
          <el-col :span="3" class="col_label">完成率比例</el-col>
          <el-col :span="3" class="col_view">{{form.materialCompleteProportion}}</el-col>
        </el-row>
      </el-form>
      <div class="cleardix panel_end">
        <p>竞标供应商清单：</p>
      </div>
      <el-table :data="bidding" border>
        <!-- <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="text">发送中标通知</el-button>
          </template>
        </el-table-column> -->
        <el-table-column :show-overflow-tooltip="true" label="供应商编码" align="center" prop="vendorCode"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="供应商名称" align="center" prop="vendorName"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="中标状态" align="center" prop="mobilePhone">
          <template slot-scope="scope">
            <TableIcon :flag="scope.row.mobilePhone" :titles="[{status:0,title:'未中标'},{status:1,title:'部分中标'}]">
            </TableIcon>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="中标标的数" align="center" prop="checkPassNum"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="中标金额" align="center" prop="checkMoney"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="中标通知" align="center" prop="checkPassNotic"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="合同签订状态" align="center" prop="isContract"></el-table-column>
      </el-table>
      <div class="cleardix panel_end">
        <p class="fl fr_right">中标清单：</p>
        <!-- <p class="fl fr_right">预计总降本金额为xxxx</p>
        <p class="fl">降本幅度：xx%</p> -->
      </div>
      <el-table :data="list" border>
        <el-table-column :show-overflow-tooltip="true" label="供应商编码" align="center" prop="vendorCode"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="供应商名称" align="center" prop="vendorName"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="物料编码" align="center" prop="materialCode"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="物料名称" align="center" prop="vendorName"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="预计采购量" align="center" prop="planQty"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="参考价格" align="center" prop="mobilePhone"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="中标价格" align="center" prop="lastNoTaxPrice"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="中标金额" align="center" prop="checkPassAllMoney"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="中标通知" align="center" prop="sendCheckNotic"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" label="预计降本金额" align="center" prop="expectedDrop"></el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
  import timeLine from '@/components/timeline.vue';
  import TableCell from '@/components/common/table-ext/table-cell';
  import TableIcon from '@/components/common/table-ext/table-icon';
  export default {
    components: {
      TableIcon,
      timeLine
    },
    data() {
      return {
        //业务日志
        showInfo: true,
        infourl: this.lib.config.host.system + '/system/log/getList',
        formData: {
          moduleCode: 'RFQ',
          businessId: this.$route.query.id
        },
        //业务日志   
        isShow: false,
        list: [],
        bidding: [],
        form: {}
      };
    },
    created() {
      this.init()
    },
    methods: {
      //再次询价
      againInquiry() {
        this.$confirm('再次询价将会复制这条询价数据，形成新的询价单!确定要执行此操作吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.axios.post(this.lib.config.host.rfq + "/ctmgt/rfq/enquiry/finish/rfqCopy/" + this.$route.query.id)
            .then((response) => {
              //this.$refs['tableExt'].refreshTable();
              if (response.data.success) {
                this.$message({
                  type: 'success',
                  message: '成功创建新的询价单，请进入【创建询价】或刷新询价单列表数据查看!'
                });
              }
            })
            .catch((error) => {
              console.log(error)
            });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消再次询价'
          });
        });
      },
      closeDialog() {
        this.showInfo = false;
      },
      init() {
        //获取基本信息
        this.axios.get(this.lib.config.host.rfq + '/ctmgt/rfq/enquiry/finish/finishQuery/' + this.$route.query.id)
          .then((response) => {
            debugger
            console.log(778999)
            console.log(response)
            console.log(response.data.resultMap.rfqMainDto)
            this.form = response.data.resultMap.rfqMainDto;    
            this.bidding = response.data.resultMap.queryVendorsList;
            this.list = response.data.resultMap.vendorMaterialList;
            if (response.data.resultMap.rfqMainDto=='') {
              this.isShow = false;
            } else {
              this.isShow = true;
            }
          })
          .catch(function (error) {
            console.log(error);
          });
      }
    }
  }

</script>
